<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
// To verify "mac" behavior other than macOS, please add following lines:
//   internals.settings.setEditingBehavior('mac');
//   internals.settings.setSelectTrailingWhitespaceEnabled(false);
const isMac = navigator.platform.indexOf('Mac') === 0;

selection_test(
  '<div contenteditable dir="ltr">|abc ghi<div></div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc ghi<div></div><div></div><div></div></div>',
  '8-0 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">a|bc ghi<div></div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc ghi<div></div><div></div><div></div></div>',
  '8-1 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">ab|c ghi<div></div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc ghi<div></div><div></div><div></div></div>',
  '8-2 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc| ghi<div></div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc ghi<div></div><div></div><div></div></div>',
  '8-3 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">|abc ghi<div></div><div></div><div></div></div>',
  '8-4 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc g|hi<div></div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-5 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc gh|i<div></div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-6 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc ghi|<div></div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-7 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc ghi<div>|</div><div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-8 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc ghi<div></div>|<div></div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-9 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc ghi<div></div><div>|</div><div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-10 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc ghi<div></div><div></div>|<div></div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-11 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc ghi<div></div><div></div><div>|</div></div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-12 ltr left word');

selection_test(
  '<div contenteditable dir="ltr">abc ghi<div></div><div></div><div></div>|</div>',
  selection => selection.modify('move', 'left', 'word'),
  '<div contenteditable dir="ltr">abc |ghi<div></div><div></div><div></div></div>',
  '8-13 ltr left word');
</script>
